import torch
from diffusers import StableDiffusionPipeline, DDIMScheduler, UniPCMultistepScheduler,KDPM2DiscreteScheduler

pipe = StableDiffusionPipeline.from_pretrained(
    "C:/Users/Administrator/Downloads/revAnimated_v122",
    safety_checker=None,
    # revision="fp16",
    # custom_pipeline="lpw_stable_diffusion",
    # local_files_only=True,
    torch_dtype=torch.float16,
    # use_auth_token=True
)
# pipe.scheduler = UniPCMultistepScheduler.from_config(pipe.scheduler.config)
# pipe.scheduler = KDPM2DiscreteScheduler.from_config(pipe.scheduler.config)
import os
os.environ['CURL_CA_BUNDLE'] = ''
# パイプラインの準備

pipe = pipe.to("cuda")
pipe.enable_xformers_memory_efficient_attention()
# pipe.enable_sequential_cpu_offload()
# pipe.enable_attention_slicing()
# pipe.vae.enable_tiling()

# 推論の実行
prompt = "pretty 1girl, absurdres, 8k uhd, platinum blonde hair, bob cut, medium breasts, black tshirt, denim shorts, garden background, flowers, magnolias, apple tree, close up portrait"
negative_prompt = "3d, cartoon, anime, sketches, (worst quality, bad quality, child, cropped:1.4) ((monochrome)), ((grayscale)), (bad-hands-5:1.0), (badhandv4:1.0), (easynegative:0.8), (bad-artist-anime:0.8), (bad-artist:0.8), (bad_prompt:0.8), (bad-picture-chill-75v:0.8), (bad_prompt_version2:0.8), (bad_quality:0.8)"

image = pipe(
    prompt, 
    width=1024,
    height=512,
    num_inference_steps=30
).images[0]
# 当前时间 yyyy-mm-dd-hh-mm-ss
import datetime
now = datetime.datetime.now()
# 转换为指定的格式:
otherStyleTime = now.strftime("%Y_%m_%d_%H_%M_%S")
image.save("../data/original_" + otherStyleTime + ".png")